package com.sunday.haowushop.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.sunday.haowushop.R;


import butterknife.ButterKnife;

/**
 * Created by 刘涛 on 2017/4/17.
 */

public class ShopFragmentAdapter extends RecyclerView.Adapter {

    private final static int TYPE_HEAD=0;
    private final static int TYPE_LIST=1;

    private Context mContext;

    public ShopFragmentAdapter(Context context){
        mContext=context;
    }


    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        switch (viewType){
            case TYPE_HEAD:
                View view= LayoutInflater.from(mContext).inflate(R.layout.layout_img_gallery,null);
                return new HeaderHolder(view);
            case TYPE_LIST:
                view=LayoutInflater.from(mContext).inflate(R.layout.layout_shop_fragment_item,null);
                return new ListHolder(view);
        }
        return null;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

    }

    @Override
    public int getItemCount() {
        return 10;
    }

    @Override
    public int getItemViewType(int position) {
        if (position==0){
            return TYPE_HEAD;
        }else {
            return TYPE_LIST;
        }
    }

    class HeaderHolder extends RecyclerView.ViewHolder {

        public HeaderHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }

    class ListHolder extends RecyclerView.ViewHolder {

        public ListHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
